package main

import (
	"github.com/go-kratos/kratos/contrib/registry/eureka/v2"
	"github.com/go-kratos/kratos/v2/registry"

	"helloworld/internal/conf"
)

type registrySet []registry.Registrar

func NewRegistrySet(application *conf.Application) registrySet {
	rs := make(registrySet, 0, 4)

	//1.registry eureka
	rs = append(rs, NewEurekaRegistrar(application.Eureka))

	//2.other ...

	return rs
}

// address format : http://username:password@localhost:8761/eureka
func NewEurekaRegistrar(conf *conf.Eureka) registry.Registrar {
	rg, err := eureka.New([]string{conf.Address},
		eureka.WithEurekaPath("eureka"),
	)
	if err != nil {
		panic(err)
	}
	return rg
}
